package com.cee.admin.modules.ca;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cee.admin.common.BaseController;
import com.cee.common.web.result.Result;
import com.cee.domain.common.form.BaseAuditForm;
import com.cee.domain.modules.ca.query.CaTransferApplicationQuery;
import com.cee.domain.modules.ca.vo.CaTransferApplicationVo;
import com.cee.ds.common.constants.PermissionConstants;
import com.cee.ds.modules.ca.service.ICaTransferApplicationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author wsz
 * @since 2024/3/11
 */
@RestController
@RequestMapping("/api/ca/transfer")
@Tag(name = "项目管理")
public class CaTransferApplicationController extends BaseController {

    @Autowired
    private ICaTransferApplicationService transferApplicationService;

    @PostMapping("/audit")
    @Operation(summary = "碳信用转移管理-审核")
    @RequiresPermissions(PermissionConstants.CA_TRANSFER_PREFIX + PermissionConstants.AUDIT)
    public Result<Boolean> audit(@RequestBody @Valid BaseAuditForm auditForm) {
        transferApplicationService.audit(auditForm);
        return success(true);
    }

    @GetMapping("page")
    @Operation(summary = "碳信用转移管理-分页")
    @RequiresPermissions(PermissionConstants.CA_TRANSFER_PREFIX + PermissionConstants.READ)
    public Result<IPage<CaTransferApplicationVo>> page(@Valid CaTransferApplicationQuery query) {
        return success(transferApplicationService.adminPage(query));
    }

}